import 'package:flutter/material.dart';
import 'package:get/get.dart';

class MainPageController extends GetxController {
  final _currentSelectedTabIndex = 0.obs;

  int get currentSelectedTabIndex => _currentSelectedTabIndex.value;

  // 分页管理
  final PageController pageController = PageController();

  void onPageIndexChanged(int index) {
    if (_currentSelectedTabIndex.value != index) {
      _currentSelectedTabIndex.value = index;
    }
  }

  void onTabChanges(int index) {
    if (_currentSelectedTabIndex.value != index) {
      _currentSelectedTabIndex.value = index;
      pageController.jumpToPage(index);
    }
  }

  @override
  void onClose() {
    pageController.dispose();
    super.onClose();
  }
}
